// 2025/9/18
// 有效的数独

class Solution {
public:
    bool isValidSudoku(vector<vector<char>>& board) {
        vector<vector<bool>> palace(9, vector<bool>(10, false));
        vector<vector<bool>> row(9, vector<bool>(10, false));
        vector<vector<bool>> col(9, vector<bool>(10, false));
        int m = board.size(), n = board[0].size();
        for(int i = 0; i < m; i++)
        {
            for(int j = 0; j < n; j++)
            {
                if('1' <= board[i][j] && board[i][j] <= '9')
                {
                    int num = board[i][j] - '0';
                    int pala_seq = i / 3 * 3 + j / 3;
                    if(palace[pala_seq][num] || row[i][num] || col[j][num])
                        return false;
                    palace[pala_seq][num] = row[i][num] = col[j][num] = true;
                }
            }
        }
        return true;
    }
};